﻿using Landpy.CruiseControlNet.ConfigurationSidekick.ConfigTreeModule;
using Landpy.CruiseControlNet.ConfigurationSidekick.ParserModule;

namespace Landpy.CruiseControlNet.ConfigurationSidekick.ConfigPropertyModule
{
    class AssemblyHandler : GetPropertiesHandler
    {
        public override object GetPropertiesObject(GetPropertiesContext getPropertiesContext)
        {
            var treeNodeIndentity = this.GetTreeNodeIndentity(getPropertiesContext);
            if (treeNodeIndentity.Type == TreeNodeType.Assembly)
            {
                AssemblyKey assemblyKey = AssemblyKeyUtil.GetKey(treeNodeIndentity.Key);
                return this.AssemblyRepository.GetAssemblyById(getPropertiesContext.CruiseControl, assemblyKey.ProjectId,
                                                               assemblyKey.NUnitId, assemblyKey.Id);
            }
            return this.Successor.GetPropertiesObject(getPropertiesContext);
        }
    }
}
